package com.shop.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.shop.bean.Page;
import com.shop.service.GoodsService;
import com.shop.service.impl.GoodsServiceImpl;

@WebServlet("/GoodsServlet")
public class GoodsServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		GoodsService gs=new GoodsServiceImpl();
		int pageNum;//页号
		int pageSize;//页大小
		if(request.getParameter("pageNum")!=null) {
			pageNum=Integer.parseInt(request.getParameter("pageNum"));
		}else {
			pageNum=1;
		}
		
		if(request.getParameter("pageSize")!=null) {
			pageSize=Integer.parseInt(request.getParameter("pageSize"));
		}else {
			pageSize=5;
		}
		
		Page page=gs.selectALLGoods(pageNum, pageSize);
		System.out.println(page.getTotalPages()+"哈哈哈");
		request.setAttribute("page",page);
		request.getRequestDispatcher("goods.jsp").forward(request, response);
	}
}
